<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="oneroom.admin.member.MemberDao" scope="page"/>
<jsp:useBean id="code" class="oneroom.admin.code.codeDao" scope="page"/>
<%@ page import="oneroom.admin.member.MemberModel" %>
<%@ page import="oneroom.admin.code.codeModel" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List" %>
<% 
	//자신의 코드값을 셋팅한다.
	HashMap paramMap = new HashMap();
	
	String	pageName		= "list.jsp";
	String	viewName		= "view.jsp";
	int		giSelectPage	= Integer.parseInt(request.getParameter("txtSelectPage")	== null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int		giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock")	== null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	String	memberGubn		= request.getParameter("memberGubn")	== null ? "" : request.getParameter("memberGubn");		//검색 구분값
	String	searchGubn		= request.getParameter("searchGubn")	== null ? "" : request.getParameter("searchGubn");		//검색 구분값
	String	searchValue		= request.getParameter("searchValue")	== null ? "" : request.getParameter("searchValue");		//검색어
	//페이지 관련 
	int		giCount       	= 0;			//리스트 for문 break문에 사용
	int		giRecordcnt   	= 0;			//리스트의 카운터에 사용
	int		giPageSize    	= 5;  			// 한페이지에 나타내고자 하는 List수
	int     giBlockSize   	= 5;   			// Block의 수
	int     giCurPage     	= 1;   			// 현재 Page
	int     giCurBlock    	= 0;   			// 현재 Block
	int     giStartPos    	= 0;   			// 시작 List 위치
	int     giTotPage     	= 0;   			// 총 Page수
	int     giTotBlock    	= 0;   			// 총 Block수
	
	//  넘겨온 값 받기(List페이지 관련)...
	if ( giSelectPage  >  0 ) { 		// 선택된 Page값이 있을경우....     
		giCurPage  = giSelectPage;   	// 현재Page = 선택된Page 
		giCurBlock = giSelectBlock;  	// 블락page = 선택된 블락 page
	}
	
	paramMap.put("searchGubn",searchGubn);
	paramMap.put("memberGubn",memberGubn);
	paramMap.put("searchValue",searchValue);
	paramMap.put("giCurPage",giCurPage+"");
	paramMap.put("pageSize",giPageSize+"");
	
	ArrayList returnList =  member.getList(paramMap);
	List list = code.getDtlList("100");
	if (returnList.size() > 0 ) {
		giRecordcnt = member.cnt; 			// 총 list 수
	}
	if (giRecordcnt > 0) {  // 조건에 맞는 값이 있으면....
		giTotPage  = giRecordcnt / giPageSize;
		if (giRecordcnt % giPageSize != 0) {
			giTotPage = giTotPage + 1;			// 총 Page수를 구한다...
		}
		giTotBlock = giTotPage / giBlockSize;
		if (giTotPage % giBlockSize != 0) {
			giTotBlock = giTotBlock + 1;		// 총 Block수를 구한다...
		}
	}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>회원관리</title>
<script type="text/javascript" src="/admin/js/default.js"></script>
<script type="text/javascript" src="/admin/js/jquery-1.3.2.min.js"></script>
<link href="/admin/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
$(document).ready(function(){
	$('#wrtBtn').click(function() {
		window.location.href="write.jsp";
	});
	$('#regBtn').click(function() {
		window.location.href="regi_agr.jsp";
	});	
	$('#findBtn').click(function() {
		window.location.href="find_id.jsp";
	});	
});
//-->
</script>
</head>
<body>
<!-- Header  Start -->
<div id="bodywrap">
<div class="all-wrap">
<%@ include file="/admin/common/top.jsp" %>
<div id="right-wrap">
<%@ include file="/admin/common/navi.jsp" %>
<!--Contents Start-->
<div id="content">
<div class="path"><span>home</span> >  회원관리 </div>
<h4>회원</h4>
<p class="sub-text">회원 관리 하실 수 있습니다.</p>
<form name="frm" id="frm"  action="list.jsp" method="post" >
  <div class="list-search">
    <fieldset>
      <legend>게시판 내용 검색</legend>
      <p>
        <label for="select-board02">항목</label>
        <select id="select-board02" class="selectMain" style="width: 80px;" name="memberGubn">
          	<option value="Y" <%if(memberGubn.equals("Y")){out.println(" selected ");} %> >가입회원</option>
			<option value="N" <%if(memberGubn.equals("N")){out.println(" selected ");} %>>탈퇴회원</option>
			<option value="all" <%if(memberGubn.equals("all")){out.println(" selected ");} %>>전체</option>
		</select>      
        <label for="select-board02">항목</label>
        <select id="select-board02" class="selectMain" style="width: 80px;" name="searchGubn">
          	<option value="id" <%if(searchGubn.equals("id")){out.println(" selected ");} %> >ID</option>
			<option value="name" <%if(searchGubn.equals("name")){out.println(" selected ");} %>>이름</option>
			<option value="all" <%if(searchGubn.equals("all")){out.println(" selected ");} %>>전체</option>
		</select>
        <label for="select-search">검색어</label>
        <input id="select-search" type="text" value="<%=searchValue %>" name="searchValue" style="width: 120px;"/>
        <input type="submit" value="검색" class="btn-black"  />
      </p>
      <p>&nbsp;</p>
    </fieldset>
  </div>
</form>  


<p class="board-total">전체 게시물수 <span><%=giRecordcnt %></span></p>
<table class="list-normal" cellpadding="0" cellspacing="0" summary="EVENT" >
  <caption>회원 목록</caption>
  <col width="10%" />
  <col width="20%" />
  <col width="20%" />
  <col width="20%" />
  <col width="10%" />
  <col width="20%" />
  <thead>
    <tr>
      <th scope="col" >No</th>
      <th scope="col" >구분</th>
      <th scope="col" >ID</th>
      <th scope="col" >이름</th>
      <th scope="col" >가입여부</th>
      <th scope="col" >등록일</th>
    </tr>
  </thead>
  <tbody>
<%
	if(returnList != null && returnList.size() > 0){
		   giCount  = 1;
	       giRecordcnt = giRecordcnt - ( giCurPage -1 ) * giPageSize;	
		   giStartPos = ((giCurPage - 1) * giPageSize) + 1;
		for(int i = 0; i<returnList.size(); i++){
			MemberModel model = (MemberModel)returnList.get(i);
%>      
    <tr>
      <td><%=giRecordcnt %></td>
<%
for(int j = 0; j<list.size(); j++){
	codeModel codemodel = (codeModel)list.get(j);
	if(codemodel.getCode().equals(model.getAuthorize())){
%>
      <td><%=codemodel.getCodename()%></td>
<%	}
} 
%>
      <td><a href="<%=viewName%>?id=<%=model.getId()%>&txtSelectPage=<%=giSelectPage%>&txtSelectBlock=<%=giSelectBlock%>&searchGubn=<%=searchGubn%>&searchValue=<%=searchValue%>"><%=model.getId()%></a></td>
      <td><%=model.getName()%></td>
      <td><% if(model.getUseyn().equals("Y")){%>가입<%}else{ %>탈퇴<%} %></td>
      <td><%=model.getCreatedate()%></td>
    </tr>
<%
		giCount = giCount + 1;
		giRecordcnt = giRecordcnt - 1;
		}
	}else{
%>	
	<tr>
	<td colspan="6"> 등록된 내용이 없습니다.</td>
	</tr>
<%	
	}
%>   
  </tbody>
</table>
<div class="page-num">
<%@ include file="/admin/common/pages.jsp" %>
<div class="btn-all-align2">
<span class="btn-align">
<!-- <input type="button" value="등록" class="btn-bg-gray" id="wrtBtn" /> 
<input type="button" value="회원가입확인" class="btn-bg-gray" id="regBtn"/><input type="button" value="아이디찾기" class="btn-bg-gray" id="findBtn" /></span>
-->
</div>
</div>
</div>


<!--Contents End-->
</div>
</div>
</div>
<!--Footer Start-->
<%@ include file="/admin/common/bottom.jsp" %>
<!--Footer End-->
</body>
</html>